﻿using System;

namespace MCP.Data.Client.Message
{
	/// <summary>
	/// RegularMessage with current balance status.
	/// </summary>
	public class CurrentBalanceMessage : MessageBase
	{
		private const string Mask = "Your current balance is <span class='regular-message-current-balance'>{0}</span> (<span class='regular-message-percent'>{1}%</span> left till min balance reached).";
		private const string EmptyMask = "Specify your month income in <a class='regular-message-settings-link' href='/ChecksList/Settings'>Settings</a> to see your current finances state regularly.";

		/// <summary>
		/// Compose message text.
		/// </summary>
		/// <param name="currentBalance">Current balance.</param>
		/// <param name="percent">Percentage.</param>
		public void ComposeMessage(double? currentBalance, double? percent)
		{
			if (currentBalance.HasValue && percent.HasValue)
			{
				this.Text = string.Format(
					Mask,
					Math.Round(currentBalance.Value, 2),
					Math.Round(percent.Value, 2));
			}
			else
			{
				this.Text = EmptyMask;
			}
		}
	}
}